#! /bin/sh

if [ ! -d "${MAPREDUCE_HOME}" ]; then
    echo "\${MAPREDUCE_HOME} is not set." >&2
    exit 1
fi

if [ -z "$1" ]; then
    echo "no number of points." >&2
    exit 1
fi

if [ -z "$2" ]; then
    echo "no N" >&2
    exit 1
fi

NLOOP=10
NUMPOINTS=$1
N=$2

JAR=./target/mapreduce-example.jar
GENPOINTS=
KMEANS=org.sss.mapreduce.example.KMeans
KMRESULT=org.sss.mapreduce.example.KMeansResultPrinter

date '+@ kmeans_start %Y%m%d%H%M%S'

KEY_FILE=lastCommID
KEY_FILE2=lastCommID2

inputid=`bin/run.sh ${JAR} org.sss.mapreduce.example.GenPoints -p ${NUMPOINTS}` || exit 1
echo $inputid
bin/run.sh ${JAR} org.sss.mapreduce.example.KMeans -n${NLOOP} ${N} ${inputid} || exit 1

date '+@ kmeans_done %Y%m%d%H%M%S'
